package com.demo.resourcecode.c13jms;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;

import javax.jms.Destination;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;

public class MainTest {

	public static void main(String[] args) throws Exception{
		ApplicationContext act = new ClassPathXmlApplicationContext("jms.xml");
		JmsTemplate jmsTemplate = (JmsTemplate)act.getBean("jmsTemplate");
		Destination destination = (Destination)act.getBean("destination");
		jmsTemplate.send(destination, new MessageCreator() {
			@Override
			public Message createMessage(Session session) throws JMSException {
				return session.createTextMessage("this is a test message");
			}
		});
	}

}
